#ifndef NETWORKSERVER_H
#define NETWORKSERVER_H

#include <QTcpServer>
#include <QTcpSocket>
#include <QSettings>

class NetworkServer : public QTcpServer
{
    Q_OBJECT
public:
  explicit NetworkServer(QObject *parent = 0);
  void startServer();
  void sendData(QByteArray data);
  bool isClientConnected();

  void setClientIP(QString ip);
  void setHostIP(QString hostIP);
  void setTcpPort(quint16 port);

  QString getClientIP();
  QString getHostIP();
  quint16 getTcpPort();
private:
  QString serverIP;
  quint16 tcpPort;
  QString clientIP;
  bool anyClientConnected;

  QTcpServer *server;
  QTcpSocket *socket;
signals:  
  void dataReady(QByteArray);
  void socketError(const int &errorCode, const QString &errorString);
  void clientConnected();
  void clientDisconnected();
public slots:
  void newConnection();
  void dataReceived();
  void disconnected();
  void networkError(QAbstractSocket::SocketError error);//Network error
protected:
};

#endif // MYSERVER_H
